package com.etv.launcher.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;

import com.etv.launcher.model.entity.ApplicationInfoEntity;

import java.util.List;

@Dao
public interface ApplicationInfoDao extends BaseDao<ApplicationInfoEntity> {

    /**
     * 获取所有应用列表
     * @return
     */
    @Query("SELECT * FROM APPLICATION_INFO")
    List<ApplicationInfoEntity> queryApplicationList();

    @Query("SELECT APPLICATION_ID FROM APPLICATION_INFO")
    List<String> queryAllPackageName();

    @Query("SELECT * FROM APPLICATION_INFO WHERE VISIBLE = 1 ORDER BY UPDATE_TIME ASC,APP_NAME")
    LiveData<List<ApplicationInfoEntity>> queryApplicationListLive();

    /**
     * 根据包名删除应用
     * @param packageName
     */
    @Query("DELETE FROM APPLICATION_INFO WHERE APPLICATION_ID IN (:packageName)")
    void deleteByPackageNames(List<String> packageName);

}
